package cn.zyl.common.redis.exception;

/** MiniRedisDataException 异常类说明: redis重定向异常
 * @author wsz
 * @date 2020-08-11
 * @version v1.0
 */
public class MiniRedisRedirectionException extends MiniRedisDataException {
    /** 集群槽点*/
    private int slot;
    /** IP地址*/
    private String host;
    /** 端口*/
    private int port;
    public MiniRedisRedirectionException(String msg){ super(msg);}
    public MiniRedisRedirectionException(String msg, String host, int port, int slot){
        super(msg);
        this.host = host;
        this.port = port;
        this.slot = slot;
    }
    public MiniRedisRedirectionException(Throwable e){ super(e);}
    public MiniRedisRedirectionException(String msg, Throwable e){ super(msg,e);}
    public static void isTrueThrow(boolean boo,String msg) throws MiniRedisRedirectionException {
        if(boo){throw new MiniRedisRedirectionException(msg);}
    }
    public static void isTrueThrow(boolean boo,Throwable e) throws MiniRedisRedirectionException {
        if(boo){throw new MiniRedisRedirectionException(e);}
    }
    public static void isNullThrow(Object o,String msg) throws MiniRedisRedirectionException {
        isTrueThrow(null == o,msg);
    }
    public int getSlot() { return slot; }
    public String getHost() { return host; }
    public int getPort() { return port; }
}